package cn.clouds234.net;


/**
 * @author wyf
 * @date 2025/2/26 15:22
 */
public class UrlDemo {
    public static void main(String[] args) throws Exception {
        String image = "www.baidu.com:32654/ffdafd/fdas:1.0";
//        URL url1 = new URL(url);
//        String host = url1.getHost();
//        System.out.println(host);
//        System.out.println(url1.getPath());
//        System.out.println(url1.getProtocol());
        String[] split = image.split("//");
        StringBuilder addr = new StringBuilder();
        if (split.length > 1){
            addr.append(split[0]);
            addr.append("//");
            int index = split[1].indexOf("/");
            if (index == -1) {
                throw new Exception("制品路径错误");
            }
            addr.append(split[1], 0, index);
        } else {
            addr.append(image, 0, image.indexOf("/"));
        }
        System.out.println(addr);
    }
}
